package com.smartboot.plus.wapper;


import com.alibaba.fastjson2.JSONObject;
import com.smartboot.plus.ignite.cache.MqttClientCache;
import com.smartboot.plus.support.BaseMqttEntityWrapper;
import com.smartboot.plus.utils.Func;
import com.smartboot.plus.vo.MqttClientVO;

public class ConnectionWrapper extends BaseMqttEntityWrapper<MqttClientCache, MqttClientVO> {

    public static ConnectionWrapper build() {
        return new ConnectionWrapper();
    }

    @Override
    public MqttClientVO entityVO(MqttClientCache entity) {
        if (Func.isEmpty(entity)) {
            return new MqttClientVO();
        }
        // 将 entity 转换为 JSON 字符串，再解析为 SmartMqttConnectionVO
        String json = JSONObject.toJSONString(entity);
        MqttClientVO mqttClientVO = JSONObject.parseObject(json, MqttClientVO.class);
        return mqttClientVO;
    }
}
